#include <iostream>
using namespace std;
struct node{
	int data;
	node *next;
};

int main(){
	node *head=NULL;
	int temp;
	node *tail=NULL;
	cin>>temp;
	while(temp!=-1){
		node *n1=new node;
		n1->data=temp;
		n1->next=NULL;
		if(head==NULL){
			head=n1;
			tail=n1;
		}else{
			tail->next=n1;
			tail=n1;
		}
		cin>>temp;
	}
	//cout<<sizeof(node)<<endl<<sizeof(a)<<endl<<sizeof(tail)<<endl<<sizeof(int);
	tail=head;
	while(tail!=NULL){
		//cout<<(*tail).data;
		cout<<tail->data<<" ";
		tail=tail->next;
	}
//	a.next=&a;
//	cin>>a.data;
//	b.next=&b;
//	cin>>b.data;
//	c.next=&c;
//	cin>>c.data;
//	d.next=&d;
//	cin>>d.data;
//	e.next=&e;
//	cin>>e.data;
//	cout<<a.data<<" "<<b.data<<" "<<c.data<<" "<<d.data<<" "<<e.data;
	return 0;
}
